/*
 * PictureScanAdapter.java
 * business
 *
 * Created by SunDing on 2016/9/29.
 *
 * Copyright (c) 2016年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.adapter;

import android.content.Context;
import android.support.v4.view.PagerAdapter;
import android.view.View;
import android.view.ViewGroup;

import com.yidiandao.business.manager.ImageManager;
import com.yidiandao.business.ui.widget.photoview.PhotoView;
import com.yidiandao.business.utils.ImageLoader;

import java.util.List;

/** 用于图片浏览 */
public class PictureScanAdapter extends PagerAdapter {
    Context context;
    List<String> list;

    public PictureScanAdapter(Context context) {
        super();
        this.context = context;
        list = ImageManager.getInstance().getFinalImageList();
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {
        PhotoView photoView = new PhotoView(context);
        ImageLoader.loadActiveImageFitXY(context, photoView, list.get(position));
        container.addView(photoView);
        return photoView;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public int getItemPosition(Object object) {

        return POSITION_NONE;
    }
}
